<?php


	namespace app\controller\shop;


	use app\Request;
	use app\services\WxSystemServices;
	use app\validate\shop\WxSystemValidate;

	class WxSystemController extends ShopBaseController
	{

		/**
		 * 小程序静默授权
		 * @param Request $request
		 *
		 * @return \think\response\Json
		 * @param
		 * @throws
		 *
		 */
		public function login (Request $request) {
			$validateRes = (new WxSystemValidate())->goSceneCheck('login');
			if ($validateRes) {
				return toast($validateRes);
			}

			$wxSystemServices = app(WxSystemServices::class);

			return success($wxSystemServices->login($request));
		}


		/**
		 * 小程序解密用户信息
		 * @param Request $request
		 *
		 * @return \think\response\Json
		 * @param
		 * @throws
		 *
		 */
		public function getUserInfo(Request $request){
			$validateRes = (new WxSystemValidate())->goSceneCheck('getUserInfo');
			if ($validateRes) {
				return toast($validateRes);
			}

			$wxSystemServices = app(WxSystemServices::class);

			return success($wxSystemServices->getUserInfo($request));
		}


	}
